<template>
  <div class="cart">
    <nav-bar class="nav-bar">
      <template v-slot:center> 购物车({{ cartLength }}) </template>
    </nav-bar>

    <scroll class="content" ref="scroll">
      <cart-list />
    </scroll>
    <cart-bottom-bar />
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar";
import CartList from "./childComps/CartList.vue";
import CartBottomBar from "./childComps/CartBottomBar.vue";

import Scroll from "components/common/scroll/Scroll";
import { mapGetters } from "vuex";

export default {
  name: "Cart",
  components: {
    NavBar,
    Scroll,
    CartList,
    CartBottomBar,
  },
  computed: {
    //新知识点，getters函数映射到局部计算属性
    // ...mapGetters(["cartLength"]),
    ...mapGetters({
      cartLength: "cartLength",
    }),
  },
  activated() {
    // console.log("home activated");
    //刷新一下
    this.$refs.scroll.refresh();
  },
};
</script>

<style scoped>
.cart {
  height: 100vh;
}
.nav-bar {
  background-color: var(--color-tint);
  color: #fff;
  font-weight: 700;
}
.content {
  height: calc(100% - 137px);
  /* overflow: hidden; */
}
</style>